/*
 * @(#)BaseDomainEntity.java
 *
 * Copyright (c) 2010 sinba. All Rights Reserved.
 */
package com.sinba.common.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Lob;
import javax.persistence.MappedSuperclass;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.compass.annotations.SearchableProperty;

import com.sinba.common.dto.AbstractValueObject;

/**
 * To share common properties through a technical or a business superclass without
 * including it as a regular mapped entity (ie no specific table for this entity).
 * <p>The embedded superclass property mappings are copied into their entity subclasses.
 * Remember that the embeddable superclass is not the root of the hierarchy though.
 *
 * @version 1.00 2010-7-9
 * @author <a href="mailto:sinbawang@msn.com">Sinba Wang</a>
 */
@MappedSuperclass
public class BaseDomainEntity<ID extends Serializable>
    extends AbstractValueObject
{
    private static final long serialVersionUID = 1148750099142971324L;
    public static final Integer DELETED = 99;
    public static final Integer SYSTEM = 1;
    public static final Integer NORMAL = 0;
    public static final Integer TEST = 2;

    //    protected ID id;
    @Lob
    protected String description;
    @Column( length = 6000 )
    protected String remark;
    @Temporal( TemporalType.TIMESTAMP )
    protected Date createTime=new Date();
    @Column( length = 60 )
    protected String creator;
    @Temporal( TemporalType.TIMESTAMP )
    protected Date lastUpdateTime;
    @Column( length = 60 )
    protected String lastUpdater;
    protected Integer optimisticLock;
    @SearchableProperty
    protected Long companyNo;
    @SearchableProperty
    protected Byte dataFlag = 0; //0:normal, 1:system, 2:test,99:delete

    public BaseDomainEntity(  )
    {
    }

    public Byte getDataFlag(  )
    {
        return dataFlag;
    }

    public void setDataFlag( Byte dataFlag )
    {
        this.dataFlag = dataFlag;
    }

    /**
     * @return the description
     */
    
    public String getDescription(  ){
        return description;
    }

    /**
     * @return the remark
     */
   
    public String getRemark(  )
    {
        return remark;
    }

    /**
     * @return the createTime
     */
    
    public Date getCreateTime(  )
    {
        return createTime;
    }

    /**
     * @return the creator
     */
    public String getCreator(  )
    {
        return creator;
    }

    /**
     * @return the lastUpdateTime
     */
   
    public Date getLastUpdateTime(  )
    {
        return lastUpdateTime;
    }

    /**
     * @return the lastUpdater
     */
    
    public String getLastUpdater(  )
    {
        return lastUpdater;
    }

    /**
     * Adds optimistic locking capability.
     * <p>The optimisticLock property will be mapped to the optimisticLock column,
     * and the entity manager will use it to detect conflicting updates.
     *
     * @return the optimisticLock
     */
    public Integer getOptimisticLock(  )
    {
        return optimisticLock;
    }

    /**
     * @param description - the description to set
     */
    public void setDescription( String description )
    {
        this.description = description;
    }

    /**
     * @param remark - the remark to set
     */
    public void setRemark( String remark )
    {
        this.remark = remark;
    }

    /**
     * @param createTime - the createTime to set
     */
    public void setCreateTime( Date createTime )
    {
        this.createTime = createTime;
    }

    /**
     * @param creator - the creator to set
     */
    public void setCreator( String creator )
    {
        this.creator = creator;
    }

    /**
     * @param lastUpdateTime - the lastUpdateTime to set
     */
    public void setLastUpdateTime( Date lastUpdateTime )
    {
        this.lastUpdateTime = lastUpdateTime;
    }

    /**
     * @param lastUpdater - the lastUpdater to set
     */
    public void setLastUpdater( String lastUpdater )
    {
        this.lastUpdater = lastUpdater;
    }

    /**
     * @param optimisticLock the optimisticLock to set
     */
    public void setOptimisticLock( Integer optimisticLock )
    {
        this.optimisticLock = optimisticLock;
    }

	public Long getCompanyNo() {
		return companyNo;
	}

	public void setCompanyNo(Long companyNo) {
		this.companyNo = companyNo;
	}
    
    
}
